package org.example.controller;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.mapper.DItemMapper;
import org.example.pojo.DItem;
import org.example.pojo.select.DApplyApartmentSelect;
import org.example.pojo.select.DItemSelect;
import org.example.service.DApplyApartmentService;
import org.example.service.DItemService;
import org.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("item")
@Tag(name = "物品领用API",description = "Item Controller")
public class DitemController {

    @Autowired
    private DItemService dItemService;

    /**
     * 查询物品领用记录
     * @param dItemSelect
     * @return
     */
    @Operation(summary = "查询物品领用记录")
    @PostMapping("/selectAll")
    public Result<Map> SelectAll(@RequestBody DItemSelect dItemSelect){
        return dItemService.SelectDitems(dItemSelect);
    }

    /**
     * 更改物品领用状态
     * @param dItemSelects
     * @return
     */
    @Operation(summary = "更改物品领用状态")
    @PostMapping("/updateItem")
    public Result<Map> UpdateItem(@RequestBody DItemSelect[] dItemSelects) throws ParseException {
        return dItemService.UpdateItem(dItemSelects);
    }
    /**
     * 新增物品领用记录
     * @param dItemSelects
     * @return
     */
    @Operation(summary = "新增物品领用记录")
    @PostMapping("/addItem")
    public Result<Map> AddItem(@RequestBody DItemSelect[] dItemSelects){
        return dItemService.AddItem(dItemSelects);
    }

    /**
     * 新增物品领用记录
     * @param dItemSelects
     * @return
     */
    @Operation(summary = "新增物品领用记录")
    @PostMapping("/deleteItem")
    public Result<Map> DeleteItem(@RequestBody DItemSelect[] dItemSelects){
        return dItemService.DeleteItem(dItemSelects);
    }

}
